#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<signal.h>
#include<sys/time.h>
#include<fcntl.h>
#include<unistd.h> 
#include<pthread.h>

int  global_val = 0;

void* myfunc(void* p){
	int i = (long long) p;
	if(i == 2)
		pthread_exit(NULL);
	printf("global_val  = %d\n", global_val);
	
	return nullptr;

}
int main(int argc, char* args[])
{
	pthread_t tid;
	for(int i  = 0; i < 5; i ++){
		global_val = i;
		int ret = pthread_create(&tid, NULL, myfunc, (void*)i);
		if(ret){
			perror("pthcreate error");
			exit(1);
		}
	}

	sleep(1);
}
